package com.kehutong.common.errcode;

import org.coraframework.mvc.http.result.JSONResult;

public class Result extends org.coraframework.mvc.http.result.Result {

    public static JSONResult error(ErrorCode code) {
    	if (code == ErrorCode.WORK_OK) {
    		return success();
    	}
    	
        return new JSONResult(code.code, code.message);
    }
    
    public static JSONResult error(ErrorCode code, Object data) {
    	if (code == ErrorCode.WORK_OK) {
    		return success(data);
    	}
    	
        return new JSONResult(code.code, code.message, "data", data);
    }
}
